package com.googlecode.jtoy.patterns.singleton;

import static org.junit.Assert.*;

import java.lang.reflect.Constructor;

import org.junit.Test;

public class SingletonTest {

	@Test
	public void testCreateSingleton() {

		Singleton s = Singleton.getInstance();
		Singleton s2 = Singleton.getInstance();
		assertSame(s, s2);
	}

	@Test
	@SuppressWarnings("rawtypes")
	public void testNoPublicConstructors() throws Exception {

		Class singleton = Class.forName("com.googlecode.jtoy.patterns.singleton.Singleton");
		Constructor[] constructors = singleton.getConstructors();
		assertEquals("Singleton has public constructors.", 0, constructors.length);
	}
}
